package com.ocom.payconfig.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.common.entity.master.EntityCompanyList;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.mysql.aspect.DataSourceAspect;
import com.ocom.payconfig.dao.IDaoCompanyListInfo;
import com.ocom.payconfig.service.CompanyListInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyListInfoServiceImpl extends ServiceImpl<IDaoCompanyListInfo, EntityCompanyList> implements CompanyListInfoService {

    private final Logger log = LoggerFactory.getLogger(CompanyListInfoServiceImpl.class);

    @Autowired
    private IDaoCompanyListInfo daoCompanyListInfo;

    @DataSourceAspect(type= DataSourceEnum.MAIN_DB,isMaster = MasterSlaveEnum.SLAVE)
    @Override
    public List<EntityCompanyList> selectCompanyList() {
        QueryWrapper<EntityCompanyList> queryWrapper=new QueryWrapper<>();
        queryWrapper.apply("DATE_FORMAT(create_time,'%Y-%m') < DATE_FORMAT(NOW(),'%Y-%m')");
        return daoCompanyListInfo.selectList(queryWrapper);
    }
}
